﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BruteForceSerializer.Contract;

namespace BruteForceSerializer.Tests.TestClasses
{
	class TestSurrogate : ISerializationSurrogate
	{
		#region ISerializationSurrogate Members

		public bool ApplyOnType(Type type)
		{
			return type == typeof (KlasseMitSkalarenFeldern);
		}

		public void GetData(object obj, Dictionary<string, object> serializationData)
		{
			serializationData.Add("customizedField", ((KlasseMitSkalarenFeldern) obj).intField*2);
		}

		public object SetData(object obj, Type type, Dictionary<string, object> serializationData)
		{
			int number = (int)serializationData["customizedField"];
			((KlasseMitSkalarenFeldern) obj).intField = number*2;
			return obj;
		}

		public object CreateInstance(Type type)
		{
			return new KlasseMitSkalarenFeldern();
		}

		#endregion
	}
}